#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; ++i)
using namespace std;
const int N = 2e5 + 10;
int n;
string s;
int ans[N];

int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int minn = 0;
    memset(ans, 0, sizeof ans);
    cin >> n;
    cin >> s;
    char startfrom = s[0];
    int dep = 0;
    rep(i, 0, n) {
      if (s[i] == startfrom) {
        dep++;
        minn = max(dep, minn);
        ans[i] = dep;
      } else {
        if (dep == 0) {
        }
        ans[i] = dep;
        dep--;
      }
    }
    cout << minn << endl;
    rep(i, 0, n) { cout << ans[i] << ' '; }
    cout << endl;
  }
}
